const { Controller } = require('egg');

class OfficialBeerController extends Controller {
  async list() {
    const { ctx } = this;
    const detail = await ctx.service.officialBeer.list();
    // const detail = await ctx.service.officialBeer.add({ name: 'test' });
    console.log('[detail]', detail);
    ctx.body = {
      data: detail,
    };
  }

  async detail() {
    const { ctx } = this;
    const detail = await ctx.service.officialBeer.detail(ctx.params.id);
    ctx.body = {
      code: 0,
      data: detail,
    };
  }

  async add() {
    const { ctx } = this;
    const { body } = ctx.request;
    const detail = await ctx.service.officialBeer.add(body);
    ctx.body = {
      code: 0,
      data: detail,
    };
  }
}

module.exports = OfficialBeerController;
